package com.bdqn.zhang.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import com.bdqn.zhang.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author: tao
 * @Description: talk is cheap,show me the code!
 * @Date: create in 2020/12/4 9:39
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/getAll")
    public List<User> getAll() {
        List<User> users = new ArrayList<User>();
        users.add(new User(1, "ADMIN", new Date()));
        users.add(new User(1, "ROOT", new Date()));
        users.add(new User(1, "小白", new Date()));
        users.add(new User(1, "小黑", new Date()));
        return users;
    }


    @GetMapping("/captchaImage")
    public String getcaptchaImage() {
        //定义图形验证码的长和宽
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
        return lineCaptcha.getImageBase64();
    }


}
